{% extends 'base.html' %}

{% block js %}
    <script>
         $(function () {
            $('.submit-user').click(function () {
                $('#user-info-form').validator();
                var nickname = $('#nickname').val();
                var mail = $('#mail').val();
                var mobile = $('#mobile').val();
                var github = $('#github').val();
                var introduction_one_word = $('#introduction_one_word').val();
                var introduction_detail = $('#introduction_detail').val();
                var url = '{{ url_for('user.user_edit') }}';
                var data = {
                    'nickname': nickname,
                    'mail': mail,
                    'mobile': mobile,
                    'github': github,
                    'introduction_one_word': introduction_one_word,
                    'introduction_detail': introduction_detail,
                };
                if(nickname){
                    $.post(url, data, function (data, status) {
                        window.location.reload();
                    });
                }else{
                    console.log('error');
                    return false;
                }


            });
         });
    </script>
{% endblock %}

{% block right %}
    <div class="col-md-12 page-body">
        <div class="row">
            <div class="sub-title">
                <h2>个人信息</h2>
                <a href="{{ url_for('main.index') }}" title="返回首页"><i class="icon-home"></i></a>
            </div>
            <div class="col-md-12 content-page">
                <div class="row margin-top-30">
                    <form id="user-info-form" data-toggle="validator">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <input type="text" id="nickname" name="nickname" required class="form-control" placeholder="Your Name" value="{{ edit_user.nickname }}">
                            </div>
                        </div>

                        <div class="col-sm-6">
                            <div class="form-group">
                                <input type="email" id="mail" name="mail" required class="form-control" placeholder="Your Email" value="{{ edit_user.mail }}">
                            </div>
                        </div>

                        <div class="col-sm-6">
                            <div class="form-group">
                                <input type="text" id="mobile" name="mobile" required class="form-control" placeholder="Your Mobile Phone" value="{{ edit_user.mobile }}">
                            </div>
                        </div>

                        <div class="col-sm-6">
                            <div class="form-group">
                                <input type="text" id="github" name="github" required class="form-control" placeholder="Your Github" value="{{ edit_user.github }}">
                            </div>
                        </div>

                        <div class="col-sm-12">
                            <div class="form-group">
                                <input type="text" id="introduction_one_word" name="introduction_one_word" required class="form-control" placeholder="One Word Introduction" value="{{ edit_user.introduction_one_word }}">
                            </div>
                        </div>

                        <div class="col-sm-12">
                            <div class="textarea-message form-group">
                                <textarea id="introduction_detail" name="introduction_detail" required class="textarea-message form-control" placeholder="Your Message" rows="5">{{ edit_user.introduction_detail }}</textarea>
                            </div>
                        </div>

                        <div class="col-sm-12">
                            <div class="text-center">
                                <button type="button" class="load-more-button submit-user">保存</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
    {{ super() }}
{% endblock %}